home *** CD-ROM | disk | FTP | other *** search
- Path: cville-srv.wam.umd.edu!sartoris
- From: meade@inforum.umd.edu (Douglas S. Meade)
- Newsgroups: comp.lang.c++
- Subject: Printf behavior in Borland C++
- Date: Fri, 19 Apr 96 17:33:06 GMT
- Organization: INFORUM
- Message-ID: <4l8ipp$km1@cville-srv.wam.umd.edu>
- NNTP-Posting-Host: sartoris.umd.edu
- Summary: Behavior of printf different in BC 3.1 and BC 4.5
- Keywords: Borland, printf
- X-Newsreader: News Xpress Version 1.0 Beta #3
-
- I have a question about the behavior of the printf function with
- small negative numbers in Borland C++ 3.1 versus the same function
- in Borland C++ 4.x.
-
- The following simple program shows the problem:
-
- ________________________________________________________
- #include <stdio.h>
- #include <conio.h>
-
- void main() {
- float i, j;
- i=-0.000001;
- printf("i is (printed by %%10.3f) %10.3f\n",i);
- printf("i is (printed by %%10.7f) %10.7f\n",i);
- return;
- }
- ________________________________________________________
-
- In Borland C++ 3.1, the output is:
-
- i is (printed by %10.3f) -0.000
- i is (printed by %10.7f) -0.0000010
-
-
-
- In Borland C++ 4.5:
-
- i is (printed by %10.3f) 0.000
- i is (printed by %10.7f) -0.0000010
-
-
- My question is: Why is the negative sign getting swallowed in the
- %10.3f printf in BC4? Is this considered the correct C++ behavior?
-
- I've tested this with BC++ for OS/2 version 2.0, and it yields the
- same results as BC4.5. I haven't tested it with Watcom, Microsoft,
- or other compilers.
-
- Any help would be appreciated.
-
- Douglas Meade
-